# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=ruby-bake-bundler
pkgver=0.3.5
pkgrel=1
pkgdesc='Provides bake tasks for releasing gems using bundler'
arch=(any)
url='https://github.com/ioquatix/bake-bundler'
license=(MIT)
depends=(ruby-bake ruby-rspec)
options=(!emptydirs)
source=(https://github.com/ioquatix/bake-bundler/archive/v$pkgver/$pkgname-$pkgver.tar.gz)
sha256sums=('585d94c764396c1c7d74ec5f302285806d1f7006d6e9f5014ac0872e01efbf8c')

prepare() {
  cd bake-bundler-$pkgver
  sed -i '/bundler/d' spec/spec_helper.rb
}

build() {
  local _gemdir="$(gem env gemdir)"
  cd bake-bundler-$pkgver
  gem build bake-bundler.gemspec
  gem install \
    --local \
    --verbose \
    --ignore-dependencies \
    --no-user-install \
    --install-dir "tmp_install/$_gemdir" \
    --bindir "tmp_install/usr/bin" \
    bake-bundler-$pkgver.gem
  find "tmp_install/$_gemdir/gems/" \
    -type f \
    \( \
        -iname "*.o" -o \
        -iname "*.c" -o \
        -iname "*.so" -o \
        -iname "*.time" -o \
        -iname "gem.build_complete" -o \
        -iname "Makefile" \
    \) \
    -delete
  rm -r tmp_install/$_gemdir/cache
}

check() {
  local _gemdir="$(gem env gemdir)"
  cd bake-bundler-$pkgver
  GEM_HOME="tmp_install/$_gemdir" rspec
}

package() {
  cd bake-bundler-$pkgver
  cp -a tmp_install/* "$pkgdir"/
}
